package messagesPacks;

import java.util.Hashtable;

import Entity.BorrowRecored;
import Entity.User;

public class BorrowAndUserMessage extends GenericMessage
{

	private static final long serialVersionUID = 1L;
	private Hashtable<Integer,BorrowRecored> borrow_data;
	private Hashtable<Integer,User> user_data;
	private int bcounter,ucounter;
	
	public BorrowAndUserMessage()
	{
		this.type = msgType.BorrowAndUserMSG;
		this.borrow_data = new Hashtable<Integer,BorrowRecored>();
		this.user_data = new Hashtable<Integer,User>();
		this.bcounter = -1;
		this.ucounter = -1;
	}
	
	public void addBorrow(BorrowRecored b)
	{
		borrow_data.put(++bcounter, b);
	}
	
	public BorrowRecored getBorrow(int num)
	{
		return borrow_data.get(num);
	}
	
	public void addUser(User u)
	{
		user_data.put(++ucounter, u);
	}
	
	public User getUser(int num)
	{
		return user_data.get(num);
	}	
	
	public boolean hasGoodData()
	{
		if ((ucounter == bcounter) && (ucounter >= 0))
			return true;
		return false;
	}
	
	public int getCounter()
	{
		return bcounter;
	}
	
}
